package com.jmu.employee;

import java.util.*;

public class TestStaff {

    private static void printName(Staff[] staffs) {
        for (Staff s:staffs
             ) {
            System.out.println(s.getName());
        }
    }

    private static void printSalary(Staff[] staffs) {
        for (Staff staff:staffs
             ) {
            System.out.println(staff.getSalary());
        }
    }

    private static void sortBySalary(Staff[] staffs) {
        Arrays.sort(staffs, new SalaryComparator());
    }

    private static void sortByAge(Staff[] staffs) {
        Arrays.sort(staffs, new AgeComparator());
    }

    private static void sortByName(Staff[] staffs) {
        Arrays.sort(staffs, new NameComparator());
    }

    private static void sortByDateHired(Staff[] staff) {
        Arrays.sort(staff, new DateHiredComparator());
    }

    public static void main(String[] args) {
        //添加若干个Staff, Teacher, SecurityGuard, Dean实例
        Staff staff = new Staff("A","AXXX",18,"boy",1500,new Date(2016,11,12));
        Staff staff1 = new Staff("E", "EXXX", 21, "woman", 2300, new Date(2017,1,8));
        Staff teacher = new Teacher("G","BXXX",32,"man",4500,new Date(1994,6,8),"Computer","soft",1200);
        Staff securityGuard = new SecurityGuard("C","CXXX",26,"man",2000,new Date(2008,10,1),"kill",1500);
        Staff dean = new Dean("D","DXXX",52,"man",6000,new Date(2015,9,8),3000);

        Staff[] employee = {staff1, teacher, securityGuard, dean, staff};

        System.out.println("打印姓名:");
        printName(employee);


        System.out.println("打印薪水排序:");
        printSalary(employee);

        System.out.println("打印薪水排序:");
        sortBySalary(employee);
        printSalary(employee);

        System.out.println("打印姓名排序:");
        sortByName(employee);
        printName(employee);

        System.out.println("打印年龄排序:");
        Arrays.sort(employee, new AgeComparator());
        for (Staff s:employee
             ) {
            System.out.println(s.getAge());
        }

        System.out.println("打印雇佣日期排序：");
        sortByDateHired(employee);
        for (Staff s:employee
             ) {
            System.out.println(s.getDateHired());
        }
    }

}
